package com.rm.zeyou.mapper;

import com.rm.zeyou.entity.TechnicianItemOrder;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.rm.zeyou.vo.response.SelectTechnicianOrderListResponseVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 * 用户订单表 Mapper 接口
 * </p>
 *
 * @author YanYang
 * @since 2025-03-12 15:55:09
 */
@Mapper
public interface TechnicianItemOrderMapper extends BaseMapper<TechnicianItemOrder> {
    TechnicianItemOrder selectOneTakingOrder(@Param("tid") Long tid);

    List<SelectTechnicianOrderListResponseVo> selectTechnicianOrderList(@Param("tid") Long tid, @Param("status") Integer status);

    @Select(" select sum(item_time) from t_technician_item_order where partner_order_no = #{orderNo} ")
    Integer selectLowerItemTime(@Param("orderNo") String orderNo);

    Integer updateOrderStatus(@Param("orderNo") String orderNo, @Param("status") Integer status);

    Integer updateStatus(@Param("orderNo") String orderNo, @Param("status") Integer status);


    Integer selectBellOrderCount(@Param("tid") Long tid);

    List<TechnicianItemOrder> selectStopOrderExceptionList();

    @Update("update t_technician_item_order set is_exception = 1 where order_no = #{orderNo}")
    Integer updateOrderException(@Param("orderNo") String orderNo);

    @Update("update t_technician_item_order set is_notify = 1 where order_no = #{orderNo}")
    Integer updateOrderNotify(@Param("orderNo") String orderNo);

    @Update("update t_technician_item_order set is_not_take_order_notify = 1 where order_no = #{orderNo}")
    Integer updateTakeOrderNotify(String orderNo);

    @Select("select count(1) from t_technician_item_order where tid = #{tid} and order_status = 5")
    Integer selectTakeOrderCount(@Param("tid") Long tid);


}
